#!/usr/bin/env python
# -*- coding: utf-8 -*-

from .. import command
from utility.odoo_manager import OdooManager

"""获取高危评分"""
def get_gwpf_value(gwpf):
    results = []
    try:
        odoo = OdooManager().get_instance()
        for gwpf_ in gwpf:
            query_ = [('id', '=', int(gwpf_))] 
            value_ = odoo.env['dict.gwpf'].search_read(query_)
            if value_:
                value_ = value_[0]
                data_ = {
                    'gwpfysCode': value_['code'],
                    'gwpfysName': value_['name'],
                    'gwpfysFz': value_['score'],
                    'gwpfysTypeCode': value_['type']
                }
                query_ = [('key', '=', int(value_['type'])),('name', '=', 'ck_gwpf_type')]
                value_ = odoo.env['dict.dictionary'].search_read(query_)
                if value_:
                    value_ = value_[0]
                    data_['gwpfysTypeName'] = value_['value']
                    results.append(data_)
    except Exception as e:
        print (e)  
    return results

